package main

import (
	"fmt"
	"net/http"
	"net/url"
	"strings"
)

func main() {
	reqUrl := "/user/infos?uid=1&tab_key=222&keyword=222"
	v, _ := url.Parse(reqUrl)
	fmt.Println(v.Query().Get("uid"))

}

//验证url包能否用
func Test1() {
	reqUrl := "/user/infos?uid=1"
	v, _ := url.ParseRequestURI(reqUrl)
	v.Query().Add("uid1", "12111") //无法改变里面的值
	fmt.Println(v.Query().Encode())
	fmt.Println(v.Query().Get("uid"))
}

func replaceTabKey(replaceStr string, req *http.Request) string {
	reqUri := req.URL.RawQuery
	tabKey := req.URL.Query().Get("tab_key")
	reqUri = strings.Replace(reqUri, "tab_key="+tabKey, fmt.Sprintf("tab_key=%v", replaceStr), -1)
	reqUri = strings.Replace(reqUri, "keyword="+tabKey, fmt.Sprintf("keyword=%v", replaceStr), -1)
	return reqUri
}
